package com.jvm.interpreter.instruction;

import com.jvm.interpreter.Frame;
import com.jvm.interpreter.Instruction;

/**
 * @program: diy_simple_jvm
 * @description: invokevirual指令
 * @author: CaoYong
 * @create: 2021-07-09 11:30
 **/
public class InvokeVirtualInst implements Instruction {

    final String clazz;
    final String name;
    final String descriptor;

    public InvokeVirtualInst(String clazz, String name, String descriptor) {
        this.clazz = clazz;
        this.name = name;
        this.descriptor = descriptor;
    }

    @Override
    public int offset() {
        return 3;
    }

    @Override
    public void eval(Frame frame) {
        final int val = frame.popInt();
        frame.popRef(); // out
        System.out.println(val);

        frame.pc += offset();
    }
}
